#include <Windows.h>
#include <iostream>

//consts

//ici, j'ai defini des constantes pour les principales couleurs possibles de la console
#define TEXT_BLANC FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_INTENSITY
#define TEXT_GRIS FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE

#define TEXT_RED FOREGROUND_RED|FOREGROUND_INTENSITY
#define TEXT_DARK_RED FOREGROUND_RED

#define TEXT_YELLOW FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_INTENSITY
#define TEXT_DARK_YELLOW FOREGROUND_RED|FOREGROUND_GREEN

#define TEXT_GREEN FOREGROUND_GREEN|FOREGROUND_INTENSITY
#define TEXT_DARK_GREEN FOREGROUND_GREEN

#define TEXT_BLUE FOREGROUND_BLUE|FOREGROUND_INTENSITY
#define TEXT_DARK_BLUE FOREGROUND_BLUE

#define TEXT_DARK_GRIS FOREGROUND_INTENSITY
#define TEXT_BLACK NULL

#define BACK_BLANC BACKGROUND_RED|BACKGROUND_GREEN|BACKGROUND_BLUE|BACKGROUND_INTENSITY
#define BACK_GRIS BACKGROUND_RED|BACKGROUND_GREEN|BACKGROUND_BLUE

#define BACK_RED BACKGROUND_RED|BACKGROUND_INTENSITY
#define BACK_DARK_RED BACKGROUND_RED

#define BACK_GREEN BACKGROUND_GREEN|BACKGROUND_INTENSITY
#define BACK_DARK_GREEN BACKGROUND_GREEN

#define BACK_BLUE BACKGROUND_BLUE|BACKGROUND_INTENSITY
#define BACK_DARK_BLUE BACKGROUND_BLUE

#define BACK_DARK_GRIS BACKGROUND_INTENSITY
#define BACK_BLACK NULL

// ici j'ai redefini les couleurs principales
#define RED TEXT_RED
#define GREEN TEXT_GREEN
#define GRIS TEXT_GRIS

#define TextColor(text, couleur) \
	SetConsoleTextAttribute(handleOut, couleur);\
	cout << text;\
	SetConsoleTextAttribute(handleOut, GRIS);

enum Direction
{
	LEFT,
	RIGHT
};

void TextFillColor(int largeur, Direction direction,
					char character, WORD color1,
					char text[], WORD color2,
					const HANDLE &handleOut)
{
	char fillText[100];
	int i;
	
	for(i = 0; i < largeur; i++)
	{
		fillText[i] = character;
	}

	for(i = 0; text[i] != '\0'; i++){}
	if(i >= largeur) i = 0;

	fillText[largeur - i] = '\0';

	if(direction == RIGHT)
	{
		SetConsoleTextAttribute(handleOut, color1);
		std::cout << fillText;
		SetConsoleTextAttribute(handleOut, color2);
		std::cout << text;
	}
	else
	{
		SetConsoleTextAttribute(handleOut, color2);
		std::cout << text;
		SetConsoleTextAttribute(handleOut, color1);
		std::cout << fillText;
	}
}